const express=require('express');
// const Message=require('../models/message');
const Expenses=require('../models/expense');
const router = new express.Router();
router.get('/performance',async(req,res)=>{
    // const result=await Message.aggregate([{
    //     $lookup:{
    //         from:'expenses',
    //         localField:'employee_id',
    //         foreignField:'employee_id',
    //         as:'performance_list'
    //     }
    // },{
    //     $match:{
    //         employee_id:req.query.employee_id
    //     }
    // }])
    // console.log(result.performance_list);
    const result=await Expenses.find(req.query,{
        _id:0,
        __v:0
    })
    let num=0
    result.forEach((item,index)=>{
        console.log(item.shishou)
        num+=item.shishou
    });
    console.log(num);
    res.send(result)
})
module.exports=router